package info.zhou.tank;

import robocode.AdvancedRobot;
import robocode.ScannedRobotEvent;

/**
 * 敌人
 * Author: zhouinfo
 * Create Date：2016-05-11 21:22
 */
public class Enemy {

    private double x;                    //x坐标
    private double y;                    //y坐标
    private String name=null;            //敌人名字
    private double headingRadian=0.0D;   //朝向
    private double bearingRadian=0.0D;   //相对我的方向
    private double distance=1000D;       //距离
    private double direction=0.0D;       //实际距离
    private double velocity=0.0D;        //运动速度
    private double energy=100.0D;        //能量

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getHeadingRadian() {
        return headingRadian;
    }

    public void setHeadingRadian(double headingRadian) {
        this.headingRadian = headingRadian;
    }

    public double getBearingRadian() {
        return bearingRadian;
    }

    public void setBearingRadian(double bearingRadian) {
        this.bearingRadian = bearingRadian;
    }

    public double getDistance() {
        return distance;
    }

    public void setDistance(double distance) {
        this.distance = distance;
    }

    public double getDirection() {
        return direction;
    }

    public void setDirection(double direction) {
        this.direction = direction;
    }

    public double getVelocity() {
        return velocity;
    }

    public void setVelocity(double velocity) {
        this.velocity = velocity;
    }

    public double getEnergy() {
        return energy;
    }

    public void setEnergy(double energy) {
        this.energy = energy;
    }

    public void update(ScannedRobotEvent e, AdvancedRobot me) {
        name = e.getName();
        headingRadian = e.getHeadingRadians();
        bearingRadian = e.getBearingRadians();
        this.energy = e.getEnergy();
        this.velocity = e.getVelocity();
        this.distance = e.getDistance();
        direction = bearingRadian + me.getHeadingRadians();
        x = me.getX() + Math.sin(direction) * distance;
        y = me.getY() + Math.cos(direction) * distance;
    }
}
